package io;

import java.io.*;

//使用缓冲流完成文件复制操作
public class CopyDemo3 {
    public static void main(String[] args) throws IOException {
        FileInputStream fis=new FileInputStream("th.jpg");
        BufferedInputStream bis=new BufferedInputStream(fis);
        FileOutputStream fos=new FileOutputStream("thcp.jpg");
        BufferedOutputStream bos=new BufferedOutputStream(fos);
        byte[] data=new byte[1024*8];
        int d;
        long start=System.currentTimeMillis();
        while((d=bis.read(data))!=-1)//块级+处理流
        {
            bos.write(d);
        }
        long end=System.currentTimeMillis();
        System.out.println("复制完成");
        System.out.println("复制时间："+(end-start)+"毫秒");
        bis.close();
        bos.close();
    }
}
